package com.hong.factory;

import com.hong.config.constant.ServerConfig;
import com.hong.strategy.PropertiesStrategy;
import com.hong.strategy.register.*;
import com.hong.strategy.rpcserver.PortStrategy;
import com.hong.strategy.rpcserver.ProtocolTypeStrategy;
import com.hong.strategy.rpcserver.TransportClassStrategy;

import java.util.HashMap;
import java.util.Map;

/**
 * @Author HQT
 * @Date 2022/7/17 16:16
 */
public abstract class PropertiesStrategyFactory {
    private static Map<String, PropertiesStrategy> strategies = new HashMap<>();

    static {
        strategies.put(ServerConfig.QRPC_TRANSPORT_MANNER, new TransportClassStrategy());
        strategies.put(ServerConfig.QRPC_SERVER_PORT, new PortStrategy());
        strategies.put(ServerConfig.QRPC_REGISTER_ADDR, new RegisterAddrStrategy());
        strategies.put(ServerConfig.QRPC_SERVICE_EXPORT, new ServiceExportStrategy());
        strategies.put(ServerConfig.QRPC_REGISTER_SCANPACKAGE, new RegisterScanPackageStrategy());
        strategies.put(ServerConfig.QRPC_REGISTER_CENTER_TYPE, new RegisterTypeStrategy());
        strategies.put("start.by.string", new StartBySpringStrategy());
        strategies.put(ServerConfig.QRPC_PROTOCOL_TYPE, new ProtocolTypeStrategy());
    }

    public static PropertiesStrategy getPropertiesStrategy(String propertiesName) {
        return strategies.get(propertiesName);
    }
}
